<!--
  ~ Copyright (c) 2020 the original author or authors
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  ~ or implied. See the License for the specific language governing
  ~ permissions and limitations under the License.
  -->
<div class="recovery-card">
  <p class="recovery-card--title">
    {{ 'login.password_recovery' | translate }}
  </p>
  <div class="content">
    <form class="form-card--form" [formGroup]="form" (ngSubmit)="onSubmit()" id="ressetForm">
      <div class="form-field" appearance="outline" hideRequiredMarker>
        <label>{{ 'login.password' | translate }}</label>
        <input
          formControlName="password"
          type="password"
          name="password"
          required
          placeholder="{{ 'change_password.new_password' | translate }}"
        />
        <div class="err" *ngIf="form.controls.password.status === 'INVALID' && form.controls.password.touched">
          <span>{{ 'registration.password_restriction' | translate }}</span>
        </div>
      </div>
      <div class="form-field" appearance="outline" hideRequiredMarker>
        <label>{{ 'login.password' | translate }}</label>
        <input
          formControlName="confirmPassword"
          type="password"
          name="confirmPassword"
          required
          placeholder="{{ 'change_password.repeate_password' | translate }}"
        />
        <div class="err" *ngIf="form.controls.password.status === 'INVALID' && form.controls.password.touched">
          <span>{{ 'registration.password_restriction' | translate }}</span>
        </div>
        <div class="err" *ngIf="form.errors?.passwordMismatch && !form.get('confirmPassword').errors?.minlength">
          <span>{{ 'registration.password_dont_match' | translate }}</span>
        </div>
      </div>
    </form>
  </div>
  <div class="recovery--container">
    <button class="btn" mat-flat-button type="submit" form="ressetForm" [disabled]="form.status === 'INVALID'">
      {{ 'common.capital.submit' | translate }}
    </button>
    <div class="link">
      <a [routerLink]="[routes.Login]">{{ 'login.login' | translate }}</a>
    </div>
    <div class="build-version">
      <span class="mat-caption">{{ 'applications.build' | translate }} {{ env.buildNumber }}</span>
    </div>
  </div>
</div>
